﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SilverlightApplication6
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(appCarregada);
        }
        Som som1;
        Som som2;
        Som som3;
        Som som4;
        private void appCarregada(object sender, RoutedEventArgs e)
        {
            som1 = new Som("Audio/bang_1.mp3", LayoutRoot);
            som2 = new Som("Audio/beep_1.mp3", LayoutRoot);
            som3 = new Som("Audio/explosion.mp3", LayoutRoot);
            som4 = new Som("Audio/explosion_2.mp3", LayoutRoot);
            App.Current.RootVisual.KeyDown += new KeyEventHandler(Jogo_keydown);
        }
        private void Jogo_keydown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.A && !som1.executando) som1.executar();
            if (e.Key == Key.S && !som2.executando) som2.executar();
            if (e.Key == Key.D && !som3.executando) som3.executar();
            if (e.Key == Key.F && !som4.executando) som4.executar();
        }
    }
}